import Vue from 'vue'
import Router from 'vue-router'

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

Vue.use(Router)
const router = new Router({
	mode: 'hash',
	base: 'shh',
	routes: [
    {
      path: '/',
      name: 'login',
      meta: {
        title: 'login',
        keepAlive: true
      },
      component: require('@/views/SystemManage/login/index').default,
    },
    {
      path: '/SystemManage',
      // name: 'SystemManage',
      meta: {
        title: '系统设置',
        keepAlive: true
      },
      component: require('@/views/SystemManage/index').default,
      children:[
        {
          path: '/',
          meta:{
            title: '首页管理'
          },
          component: require('@/views/SystemManage/firstPage/index').default
        },
        {
          path: 'paperManage',
          name: 'paperManage',
          meta:{
            title: '文章管理'
          },
          component: require('@/views/SystemManage/paperManage/index').default
        },
        {
          path: 'MemberManage',
          name: 'MemberManage',
          meta:{
            title: '成员管理'
          },
          component: require('@/views/SystemManage/MemberManage/index').default
        }
      ]
    },
	],
	scrollBehavior (to, from, savedPosition) {
		if (savedPosition) {
			return savedPosition
		} else {
			return { x: 0, y: 0 }
		}
	}
})
export default router
